package com.jinzhi.jzweb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.domain.JazGroupOrderDO;
import com.jinzhi.jzweb.domain.JazGroupProdDO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.jinzhi.jzweb.dao.JazProdTypeDao;
import com.jinzhi.jzweb.domain.JazProdTypeDO;
import com.jinzhi.jzweb.service.JazProdTypeService;
import com.jinzhi.common.base.CoreServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 
 * <pre>
 * 商品类型表
 * </pre>
 * <small> 2024-07-30 16:36:30 | Long</small>
 */
@Service
public class JazProdTypeServiceImpl extends CoreServiceImpl<JazProdTypeDao, JazProdTypeDO> implements JazProdTypeService {

    @Transactional
    @Override
    public void saveProdType(JazProdTypeDO jazProdTypeDO) {
        jazProdTypeDO.setCreateTime(new Date());
        this.insert(jazProdTypeDO);
    }

    @Override
    public Result<Page<JazProdTypeDO>> selProdTypePage(String name, int current, int size) {
        Page<JazProdTypeDO> page = new Page<>(current, size);
        List<JazProdTypeDO> voList = new ArrayList<>();
        Wrapper<JazProdTypeDO> wrapper = new EntityWrapper<>();
        if (StringUtils.isNotBlank(name)) {
            wrapper.like("name", "%" + name + "%");
        }
        Page<JazProdTypeDO> jazGroupProdDOPage = this.selectPage(page, wrapper);
        return Result.ok(jazGroupProdDOPage);
    }
}
